var proxyId="";
$(function(){
	var childFormHTML="";
	var childList=[];
	var headHTML="";
	/* 获取用户信息 */
	ym.ajax({
		url: "/user/getUser",
		success: function (data) {
		   if (data.obj) {
            proxyId=data.obj.userId;
		   	sessionStorage.setItem('curData',JSON.stringify(data.obj));
		   	headHTML+="<div class='head-top'>"+
					  "<div class='head-image'><img src='"+data.obj.headimgurl+"' alt=''></div>"+
					  "<div class='person-desc'>"+
					  "<p class='person-name-text'>"+data.obj.nickname+"</p>"+
					  "</div>"+
					  "<div class='head-more'>"+
					  "<a href='javascript:void(0)'><i class='am-icon-angle-right'></i></a>"+
					  "</div>"+
			          "</div>";
			$('header').append(headHTML);
		   }
		}
	});
	/*获取签到信息*/
	function getCheckForm(){
		ym.ajax({
			url: "/userSignIn/getContinuousSignInDay",
			success: function (data) {
			   if (data.obj) {
			   	$('.qiandao-count-day').html(data.obj.signInDays);
			   	/*是否签到*/
			   	if(data.obj.isSignIn=='1'){
			   		$('.qiandao-btn').html('已签到');
			   	}else{
			   		$('.qiandao-btn').html('签到');
			   	}
			   }
			}
		});
	}
	/*签到*/
	function checkIn(){
		ym.ajax({
			url: "/userSignIn/insertUserSignIn ",
			success: function (data) {
			   if (data.obj) {
			   	getCheckForm();
			   	$('#info-text').html('签到成功，豆豆+5')
			   	$('#ceng').modal('open');
			   	setTimeout(function(){
			   			$('#ceng').modal('close');
			   	},500)
			   }
			}
		});
	}
    /*获取用户的详细信息*/
    $('body').on('click','.head-top',function(){
        window.location.href='fixForm.html';
    })
    //查看二维码信息
	$(".ewmIng").click(function(){
        $("#userCodeImg").attr("src","");
        $.ajax({
            url: "/web/base/getImage/"+"0"+"/"+"0"+"/"+""+proxyId+""+"/"+"3600",
            success: function (data) {
                console.log(data);
                if(data.res==1){
                   $("#userCodeImg").attr("src",data.obj);
                   $(".masks").removeClass("am-hide");
                }
            }
        });
	})
    //关闭二维码信息
    $(".masks").click(function(){
        $(".masks").addClass("am-hide");
    })
	$('.qiandao-btn').click(function(){
		console.log($(this).html())
		if($(this).html()=='签到'){
			checkIn();
		}
	})
	getCheckForm();
})